using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbHinhAnhBUS
    {
        public static void Insert(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            haDAL.Insert(hinhanh);
        }
        public static void Update(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL haDAl = new tbHinhAnhDAL();
            haDAl.Update(hinhanh);
        }
        public static void Delete(int iD)
        {
            tbHinhAnhDAL haDAl = new tbHinhAnhDAL();
            haDAl.Delete(iD);
        }
        public static tbHinhAnhCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            return haDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhAnhCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            return haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.maha.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbHinhAnh GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbHinhAnhColumns.maha.ToString(), Condition.EQUAL, iD);
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            tbHinhAnhCollection haCollection = haDAL.Get(cri.Criter, 0, 0, tbHinhAnhColumns.maha.ToString(), OrderDirection.ASC.ToString(), out total);
            if (haCollection.Count > 0)
                return haCollection[0];
            return null;
        }
        public static tbHinhAnhCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            return haDAL.Get(cri.Criter, 1, number, tbHinhAnhColumns.maha.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbHinhAnhCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHinhAnhDAL haDAL = new tbHinhAnhDAL();
            return haDAL.Get(cri.Criter, 1, number, tbHinhAnhColumns.maha.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
